<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$shop['companyname']}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script src="{MODULE_URL}template/resources/js/jquery-2.1.1.min.js"></script>
<link href="{MODULE_URL}template/resources/js/bootstrap.min.css" rel="stylesheet">
<script src="{MODULE_URL}template/resources/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="{MODULE_URL}template/resources/layui/css/layui.css" media="all">
<script src="{MODULE_URL}template/resources/layui/layui.js"></script>
<link href="{MODULE_URL}template/mobile/default/base.css" rel="stylesheet">
<script src="{MODULE_URL}template/resources/js/swiper.min.js"></script>
<link href="{MODULE_URL}template/resources/js/swiper.min.css" rel="stylesheet">
<script src="{MODULE_URL}template/resources/js/let.js"></script>
<script src="{MODULE_URL}template/resources/js/webcommon.js"></script>
<script src="{MODULE_URL}template/resources/js/jquery.fly.min.js"></script>
<script src="{MODULE_URL}template/resources/js/fastclick.min.js"></script>

<style>
html,body{height:100%;overflow:hidden;font-size:14px;}
body{ margin:0; background:#EEE;background:-webkit-radial-gradient(#E89535, #D96512);background: radial-gradient(#E89535, #D96512);}
.loginbox{ margin:0 auto; width:60%; background:rgba(255,255,255,0.4); padding:20px; border-radius:4px; max-width:460px; position:relative;}
.loginbox p{ margin-bottom:10px;}
.loginbox p input{text-align:center; height:40px; line-height:40px;}
.loginbox p button{ height:40px; line-height:40px; font-size:18px}
.logoutbtn{ position:absolute; color:#FFF; top:5px; right:5px; font-size:18px}

.modal_selectpersonbox2{ padding:15px;}
.moad_inputbox{ margin-bottom:15px; position:relative;}
.moad_inputbox input{ border:none; border:1px solid #CCC;border-radius:4px; text-align:right;font-family:微软雅黑;font-size:25px;font-weight:bold;color:rgb(102, 102,102); width:100%; padding:5px 52px 5px 0}
.moad_inputbox span{ position:absolute; right:15px; top:10px; line-height:25px;font-size:25px;color:#CCC}
.modal_selectpersonbox2 .modal_body{ padding:0;overflow:hidden}
.modal_selectpersonbox2 .modal_body a{display:block;line-height:42px;border-radius:4px;background:#FFF;font-size:25px;text-align:center;font-family:Arial; margin-right:5px; border:1px solid #CCC; overflow:hidden}
.modal_selectpersonbox2 .modal_body .layui-row{ margin-bottom:8px;}
.modal_selectpersonbox2 .modal_body a.btnsure{ position:absolute; height:150px; width:84px;}


.modal_selectpersonbox{ padding:15px;}
.moad_inputbox{ margin-bottom:15px; position:relative;}
.moad_inputbox input{ border:none; border:1px solid #CCC;border-radius:4px; text-align:right;font-family:微软雅黑;font-size:25px;font-weight:bold;color:rgb(102, 102,102); width:100%; padding:5px 52px 5px 0}
.moad_inputbox span{ position:absolute; right:15px; top:10px; line-height:25px;font-size:25px;color:#CCC}
.modal_selectpersonbox .modal_body{ padding:0;overflow:hidden}
.modal_selectpersonbox .modal_body a{display:block;line-height:42px;border-radius:4px;background:#FFF;font-size:25px;text-align:center;font-family:Arial; margin-right:5px; border:1px solid #CCC; overflow:hidden}
.modal_selectpersonbox .modal_body .layui-row{ margin-bottom:8px;}
.modal_selectpersonbox .modal_body a.btnsure{ position:absolute; height:150px; width:84px;}

.orderbox{width:100%; height:100%; background:#EEE;position:relative;}
.mainmenu{position:absolute;top:0;bottom:0;left:0;width:80px;overflow:hidden;background:#393D49;text-align:center;display:-webkit-box;display:-webkit-flex;display:flex; -webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center; align-items:center;}
.mainmenu ul.mainmenubtn{ width:100%;margin-right:1px;}
.mainmenu ul.mainmenubtn li{ text-align:center; margin-bottom:20px; padding:10px 0; width:100%;}
.mainmenu ul.mainmenubtn li p i{ font-size:26px; color:#EEE}
.mainmenu ul.mainmenubtn li h3{ margin-top:5px; text-align:center; font-size:14px; color:#EEE;}
.mainmenu ul.mainmenubtn li.isselect{ background:#FFF;}
.mainmenu ul.mainmenubtn li.isselect p i{color:#333}
.mainmenu ul.mainmenubtn li.isselect h3{color:#333;}
.menulogo{ position:absolute; z-index:1; left:10px; bottom:20px; width:60px;}

.pagelist{margin-left:80px; position:relative; height:100%;}
.mianpage{height:100%;}
.goodpcatelist{position:absolute;left:0;top:0;bottom:40px;width:70px;border-right:1px solid #CCC;background:#FFF;}
.goodpcatelist ul{width:100%}
.goodpcatelist ul li{text-align:center;display:-webkit-box;display:-webkit-flex;display:flex; -webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center; align-items:center; padding:15px 5px; border-bottom:1px solid #CCC; font-size:12px}
.goodpcatelist ul li.isselect{ background:#5FB878; color:#FFF;}

.countbar{ position:absolute; z-index:1; left:0; bottom:0; right:0; height:50px; line-height:50px; border-top:1px solid #CCC; background:#FFF;transition-duration:400ms;}
.countbar .txt{ display:inline-block;padding:0 10px;}
.countbar input[type="text"]{ height:40px; line-height:40px; width:80px; background:none; border:none;padding:0 10px;}
.counterbtn{position:absolute; z-index:2;top:-10px;right:30px;}
.btn_showcar{ display:inline-block; width:50px; height:50px; border-radius:100%; background:#393D49; color:#FFF; font-size:24px; border:none;}
.countbar_menu{border-top:1px solid #CCC;line-height:16px;}
.countbar_menu table th{ background:#177ABD; color:#FFF;}
.tableNum{ text-align:center}
.tableNum span{ display:inline-block; border-radius:100%; border:1px solid #CCC; background:#FFF; text-align:center; width:26px; height:26px; line-height:26px;}
.tableNum span:active{ background:#177ABD; color:#FFF;}
.tableNum input[type="text"]{display:inline-block;width:40px;margin:0;background:#DDD;border:none;height:28px;font-family:Arial;text-align:center; line-height:28px; padding:0; border-radius:4px}
.menulistbox{ overflow-y:scroll;}

.goodlistbox{position:absolute;top:10px; bottom:55px; right:10px; left:80px;}
.goodlistbox .swiper-container{width:100%;height:300px;padding:0;margin:0}
.goodlistbox .swiper-slide {display:-webkit-box;display:-webkit-flex;display:flex;}
.goodlistbox ul{width:100%; height:100%;}
.goodlistbox ul li{width:19.5%;display:inline-block; margin-bottom:10px;position:relative;}
.goodlistbox ul li .gbox{margin-right:5px; border:1px solid #CCC; background:#FFF;}
.goodlistbox ul li .gbox p img{ width:100%; height:100px;}
.goodlistbox ul li .gbox h3{ font-size:14px; text-align:center; margin:10px; width:90%;text-overflow:ellipsis;overflow:hidden;white-space:nowrap; }
.goodlistbox ul li .gbox div{ padding:0 10px 10px 10px;}
.goodlistbox ul li .gbox div i{ color:#1E9FFF}
.goodlistbox ul li .gbox:active div i{ color:#F60}
.goodlistbox ul li .labels{ position:absolute; top:0; left:0; font-size:10px; background:#FF5722;color:#FFF; padding:2px 3px;}
.taste{ font-size:60%;}
.u-flyer{ position:absolute; z-index:9999; width:100px; height:100px; border-radius:100%;}
.ainmin{ position:absolute; z-index:99999;width:70px; height:60px;}
.ainmin img{ width:100%;}
</style>
</head>
<body>
{if $operation=="login"}

<section class="loginbox">
    <form id="loginform" action="" method="post" class="layui-form">
    <p class="text-center"><img src="{php echo tomedia($cfg['logo'])}" style="max-width:300px; max-height:200px; margin-bottom:30px"/></p>
    <p><input type="password" name="pass" lay-verify="required"  id="mpassword" onClick="mdl_selectperson(1)" readonly placeholder="请输入密码" class="layui-input"/></p>
    <p><button type="button" class="layui-btn" lay-submit lay-filter="formDemo" style="width:100%;">登陆</button></p>
    </form>
</section>

<!--人数选择-->
<div class="modal_selectperson" style="display:none">
	<div class="modal_selectpersonbox">
    	<div class="moad_inputbox">
            <input type="text" id="moadConterInput" readonly maxlength="2" value="0" />
            <span onclick="$('#moadConterInput').val($('#moadConterInput').attr('type')=='password' ? '' : '0')"><i class="fa fa-remove-sign"></i></span>
        </div>
        <div class="modal_body">
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(7,'#moadConterInput')">7</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(8,'#moadConterInput')">8</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(9,'#moadConterInput')">9</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(4,'#moadConterInput')">4</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(5,'#moadConterInput')">5</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(6,'#moadConterInput')">6</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(1,'#moadConterInput')">1</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(2,'#moadConterInput')">2</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(3,'#moadConterInput')">3</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs8"><a href="javascript:Counter(0,'#moadConterInput')">0</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter('B','#moadConterInput')"><i class="fa fa-arrow-left"></i></a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonclosebtn" class="layui-btn layui-btn-big" style="width:98%; background:#FFF; color:#333; border:1px solid #CCC;">关闭</button></div>
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonbtn" class="layui-btn layui-btn-big" style="width:98%; background:#5FB878">确定</button></div>
            </div>
        </div>
    </div>
</div>
<script language="javascript">
$(function() {  
    FastClick.attach(document.body);  
});
layui.use(['layer', 'element','form'], function(){
	var layer = layui.layer
	,element = layui.element
	,form = layui.form;
	
	var _w=$(window).width();
	var _h=$(window).height();
	var __h=$(".loginbox").height();
	$(".loginbox").css("margin-top",(_h-__h)*0.5);
	
	form.on('submit(formDemo)', function(data){
		var password=$("#mpassword").val();
		if(password.length<4){
			layer.msg("请输入密码",{icon:2,time: 2000});
			return false;
		}
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('ajax',array('op'=>'login'))}",{password:password},function(returnstr){
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				location.reload();
			}else{
				layer.close(index2);
				layer.msg(result.msg,{icon:2,time: 2000});
				return false;
			}
		})
		return false;
	});
});
function mdl_selectperson(){
	layer.open({
		type:1,
		title:"输入密码",
		area:"400px",
		skin:'layui-layer-rim',
		content:$(".modal_selectperson").show(),
		success: function(layero, index){
			$("#moadConterInput").attr("type","password").val("");
			$("#modal_selectpersonbtn").bind("click",function(){
				var num=$('#moadConterInput').val();
				if(num==0 || num.length<4){
					layer.msg("请输入密码",{icon:2,time: 2000});
					return;
				}
				$("#mpassword").val(num);
				layer.close(index);
			});
			$("#modal_selectpersonclosebtn").bind("click",function(){
				layer.close(index);
			});
		},
		end:function(){
			$(".modal_selectperson").hide();
			$("#modal_selectpersonbtn").unbind("click");
			$("#modal_selectpersonclosebtn").unbind("click");
		}
	});
}
function Counter(num,obj){
	var vTecla=num;
	var salida=$(obj);
	if(vTecla=='C'){
		salida.val('0');
		return false;
	}
	if(vTecla=='B'){
		var temp1=salida.val();
		salida.val(temp1.substr(0,temp1.length-1));
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	if(salida.val().length>8){
		return false;	
	}
	if(vTecla=='.'){
		if(salida.val().indexOf('.')>-1){
			salida.val(salida.val());
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else if(vTecla=='0'){
		if(salida.val()==0 && salida.val().length==1){
			salida.val(0);
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else{
		if((salida.val()==0 && salida.val().length==1)){
			salida.val(vTecla);
		}else{
			salida.val(salida.val()+vTecla);
		} 
	}
	var temp=salida.val();
	if(temp.indexOf('.')>-1){
		var float=temp.split('.');
		if(float[1].length>2){
			salida.val(float[0]+'.'+float[1].substr(0,2));
		}
	}
}
</script>
{else}

<input type="hidden" name="sub_person" id="sub_person"/>
<input type="hidden" name="sub_tid" id="sub_tid"/>
<input type="hidden" name="sub_userid" id="sub_userid"/>
<input type="hidden" name="sub_orderid" id="sub_orderid"/>
<div class="ainmin" style="display:none"><img src="{MODULE_URL}template/resources/img/aim_0.png"/></div>
<section class="loginbox">
    <form id="loginform" action="" method="post" class="layui-form">
    <div class="logoutbtn" onClick="fun_mainFun(4)"><i class="fa fa-remove"></i></div>
    <p class="text-center"><img src="{php echo tomedia($cfg['logo'])}" style="max-width:300px; max-height:200px; margin-bottom:30px"/></p>
    <p><button type="button" class="layui-btn layui-btn-primary" style="width:100%;font-weight:bold;color:#009688">{$shop['companyname']}</button></p>
    <p><button type="button" class="layui-btn layui-btn-primary" style="width:100%;font-weight:bold;color:#009688">服务员：{$userOper['realname']}</button></p>
    <p><button type="button" class="layui-btn layui-btn-primary" id="tablebtn" onClick="mdl_selecttable()" style="width:100%;">选择餐桌</button></p>
    <p><button type="button" class="layui-btn" lay-submit lay-filter="formDemo" style="width:100%;">开台</button></p>
    </form>
</section>

<section class="orderbox" style="display:none;">
<div class="mainmenu">
	<div class="menulogo"><img src="{php echo tomedia($cfg['logo'])}" style="width:60px;"/></div>
	<ul class="mainmenubtn">
    	<li cid="0" class="isselect" onClick="fun_mainFun(0)">
        	<p><i class="fa fa-pencil"></i></p>
            <h3>点餐</h3>
        </li>
        <!--<li onClick="fun_mainFun(1)">
        	<p><i class="fa fa-list-alt"></i></p>
            <h3>订单</h3>
        </li>-->
        <li cid="2" onClick="fun_mainFun(2)">
        	<p><i class="fa fa-bell"></i></p>
            <h3>服务员</h3>
        </li>
        <li cid="3" onClick="fun_mainFun(3)">
        	<p><i class="fa fa-th"></i></p>
            <h3>选台</h3>
        </li>
        <li cid="4" onClick="fun_mainFun(4)">
        	<p><i class="fa fa-off"></i></p>
            <h3>退出</h3>
        </li>
    </ul>
</div>

<div class="pagelist">
  <div class="mianpage">
  	<div class="goodpcatelist">
      <ul>
      	{if $isfungood}<li gcid="-1" class="isselect" onClick="fun_selectgoodpcate(-1)">限时折扣</li>{/if}
        {if $isNoPcate}<li gcid="0" onClick="fun_selectgoodpcate(0)">未分类</li>{/if}
        {loop $goodpcatelist $row}
        <li gcid="{$row['id']}" onClick="fun_selectgoodpcate({$row['id']})">{$row['title']}</li>
        {/loop}
      </ul>
    </div>
    <div class="goodlistbox">
    	<div class="swiper-container">
            <div class="swiper-wrapper">
                
            </div>
            <div class="swiper-pagination"></div>
        </div>
    </div>
    
    <div class="countbar">
      <b class="txt">总价</b>
      <input type="text" name="count_price" readonly id="count_price" value="0"/>
      <b class="txt">数量</b>
      <input type="text" name="count_num1" style="width:40px;border:none;text-align:right" readonly id="count_num1" value="0"/>/
      <input type="text" name="count_num" style="width:40px;" readonly id="count_num" value="0"/>
      <b class="txt">茶位</b>
      <input type="text" name="count_teafee" readonly id="count_teafee" value="0"/>
      <b class="txt">人数</b>
      <input type="text" name="count_person" readonly id="count_person" value="0" onClick="fun_person()"/>
      <button type="button" class="layui-btn layui-btn-normal layui-btn-small" onClick="fun_munebtn_submitorder()">下单</button>
      
      <div class="counterbtn"><button type="button" class="btn_showcar" onClick="fun_showmenu()"><i class="fa fa-shopping-cart"></i></button></div>
      <div class="countbar_menu">
      	<table class="layui-table" lay-skin="line" style="margin:0" lay-even>
          <colgroup>
            <col width="60">
            <col>
            <col width="200">
            <col width="120">
            <col width="120">
            <col width="120">
            <col width="150">
          </colgroup>
          <thead>
            <tr>
              <th>#</th>
              <th>名称</th>
              <th style="text-align:center">数量</th>
              <th>单价</th>
              <th>金额</th>
              <th>状态</th>
              <th>操作</th>
            </tr> 
          </thead>
       </table>
       <div class="menulistbox">
         <table class="layui-table" lay-skin="line" style="margin:0" lay-even>
         <colgroup>
              <col width="60">
              <col>
              <col width="200">
              <col width="120">
              <col width="120">
              <col width="120">
              <col width="150">
            </colgroup>
            <tbody id="menulist">
               
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
</section>

<!--人数选择-->
<div class="modal_selectperson" style="display:none">
	<div class="modal_selectpersonbox">
    	<div class="moad_inputbox">
            <input type="text" id="moadConterInput" readonly maxlength="2" value="0" />
            <span onclick="$('#moadConterInput').val($('#moadConterInput').attr('type')=='password' ? '' : '0')"><i class="fa fa-remove-sign"></i></span>
        </div>
        <div class="modal_body">
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(7,'#moadConterInput')">7</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(8,'#moadConterInput')">8</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(9,'#moadConterInput')">9</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(4,'#moadConterInput')">4</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(5,'#moadConterInput')">5</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(6,'#moadConterInput')">6</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(1,'#moadConterInput')">1</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(2,'#moadConterInput')">2</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(3,'#moadConterInput')">3</a></div>
            </div>
            <div class="layui-row">
              <span class="teger">
              <div class="layui-col-xs8"><a href="javascript:Counter(0,'#moadConterInput')">0</a></div>
              </span>
              <span class="float" style="display:none">
              <div class="layui-col-xs4"><a href="javascript:Counter(0,'#moadConterInput')">0</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter('.','#moadConterInput')">.</a></div>
              </span>
              <div class="layui-col-xs4"><a href="javascript:Counter('B','#moadConterInput')"><i class="fa fa-arrow-left"></i></a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonclosebtn" class="layui-btn layui-btn-big" style="width:98%; background:#FFF; color:#333; border:1px solid #CCC;">关闭</button></div>
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonbtn" class="layui-btn layui-btn-big" style="width:98%; background:#5FB878">确定</button></div>
            </div>
        </div>
    </div>
</div>
<div class="modal_selectperson2" style="display:none">
	<div class="modal_selectpersonbox2">
    	<div class="moad_inputbox">
            <input type="text" id="moadConterInput2" readonly value="0" />
            <span onclick="$('#moadConterInput').val($('#moadConterInput').attr('type')=='password' ? '' : '0')"><i class="fa fa-remove-sign"></i></span>
        </div>
        <div class="modal_body">
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(7,'#moadConterInput2')">7</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(8,'#moadConterInput2')">8</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(9,'#moadConterInput2')">9</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(4,'#moadConterInput2')">4</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(5,'#moadConterInput2')">5</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(6,'#moadConterInput2')">6</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(1,'#moadConterInput2')">1</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(2,'#moadConterInput2')">2</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter(3,'#moadConterInput2')">3</a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs4"><a href="javascript:Counter(0,'#moadConterInput2')">0</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter('.','#moadConterInput2')">.</a></div>
              <div class="layui-col-xs4"><a href="javascript:Counter('B','#moadConterInput2')"><i class="fa fa-arrow-left"></i></a></div>
            </div>
            <div class="layui-row">
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonclosebtn2" class="layui-btn layui-btn-big" style="width:98%; background:#FFF; color:#333; border:1px solid #CCC;">关闭</button></div>
              <div class="layui-col-xs6"><button type="button" id="modal_selectpersonbtn2" class="layui-btn layui-btn-big" style="width:98%; background:#5FB878">确定</button></div>
            </div>
        </div>
    </div>
</div>


<!--餐台选择-->
<style>
.modal_selecttablebox{}
.pt_menubar{ height:40px; background:#EEE; width:100%}
.pt_menuitem{text-align:center;font-size:18px;background:#fff;display:-webkit-box;display:-webkit-flex;display:flex; -webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center; align-items:center; width:16.5%; padding:1px}
.pt_menuitem a{display:block; text-align:center;border-bottom:2px solid #FFF;line-height:38px; width:100%; background:#ECF0F1}
.pt_menubar .isselect a{ background:#5FB878; color:#FFF}
.pt_tablelist{width:100%;padding:0;margin:10px 0 0 0;}
.pt_tablelist .swiper-slide{display:-webkit-box;display:-webkit-flex;display:flex;}
.pt_tablelist .swiper-slide ul{width:100%;height:100%}
.pt_tablelist .swiper-slide ul li{height:90px; min-width:110px; max-width:150px;margin:0 0 10px 0; width:16.5%; display:inline-block }
.pt_tablelist .swiper-slide ul li a{display:block;height:90px;margin-right:5px;border:1px solid #CCC;padding:5px;}
.pt_tablelist .swiper-slide ul li a h3{ font-size:20px; text-align:left; padding:0; margin-bottom:5px;}
.pt_tablelist .swiper-slide ul li a .pt_maxnum{ margin-bottom:6px;}
.pt_tablelist .status_0 a{ background:#ECF0F1;}
.pt_tablelist .status_1 a{ background:#177ABD;color:#FFF}
.pt_tablelist .status_2 a{ background:#FE893C;color:#FFF}
.page_table_list li.isselect a{background:#EEE;color:#000}
</style>
<div class="modal_selecttable" style="display:none">
	<div class="modal_selecttablebox" style="padding:15px;">
    	<div class="swiper-container pt_menubar">
          <div class="swiper-wrapper">
              {loop $tablepcatelist $row}
              <div class="swiper-slide pt_menuitem" tcid="{$row['id']}"><A href="javascript:fun_selectTablePcate({$row['id']})">{$row['title']}</A></div>
              {/loop}
          </div>
        </div>
        
        <div class="swiper-container pt_tablelist">
          <div class="swiper-wrapper">  
            
          </div>
        </div>
    </div>
</div>

<!--menumore-->
<style>
.modal_morebtnbox{ text-align:center;}
.modal_morebtnbox a{ display:inline-block;width:80px; height:80px; line-height:80px; text-align:center; border:1px solid #CCC; border-radius:4px; font-size:18px;margin:10px;}
</style>
<div class="modal_morebtn" style="display:none">
	<div class="modal_morebtnbox" style="padding:15px;">
    <input type="hidden" id="rowid" value="0"/>
    	<a href="javascript:fun_morebtn(0)" class="b1">口味</a>
        <a href="javascript:needPass(1)" class="b2">改价</a>
        <a href="javascript:fun_morebtn(2)" class="b3">上菜</a>
        <a href="javascript:fun_morebtn(3)" class="b4">删除</a>
    </div>
</div>

<!--menumore-->
<style>
.modal_morebtnbox{}
.modal_tastebox{ text-align:center; padding:10px;}
.modal_tastebox span{ border:1px solid #CCC; display:inline-block; padding:5px; min-width:60px; margin:5px; text-align:center; border-radius:4px; cursor:pointer}
.modal_tastebox span.isselect{ border-color:#90b82d; background:#90b82d; color:#FFF;}
</style>
<div class="modal_taste" style="display:none">
	<div class="modal_tastebox">
    	{loop explode(',',$shop['taste']) $row}
        <span taste="{$row}">{$row}</span>
        {/loop}
    </div>
</div>

<!--呼叫服务员-->
<style>
.modal_servicebox{ text-align:center;}
.modal_servicebox a{ display:inline-block;width:60px; height:60px; line-height:60px;text-align:center;border:1px solid #CCC;border-radius:4px; font-size:18px;margin:10px;}
</style>
<div class="modal_service" style="display:none">
	<div class="modal_servicebox" style="padding:15px;">
    	{if $shop['servicetype']}
        	{loop explode('|',$shop['servicetype']) $row}
            <a href="javascript:fun_callservice('{$row}')">{$row}</a>
            {/loop}
        {else}
    	<a href="javascript:fun_callservice('呼叫服务员')">呼叫服务员</a>
        {/if}
    </div>
</div>

<iframe src="" id="print_iframe" name="print_iframe"  style="display:none;width:1px; height:1px;"></iframe>
<script language="javascript">
window.onresize=function(){
	objectPos();
}
var tablePcateswiper=null;
var tableSwiper=null;
var goodsListSwiper=null;
$(function() {  
    FastClick.attach(document.body);
});
$(document).ready(function(e) {
    
});
layui.use(['layer', 'element','form'], function(){
	var layer = layui.layer
	,element = layui.element
	,form = layui.form;
	objectPos();
	fun_statrTable();
	
	form.on('submit(formDemo)', function(data){
		var tid=parseInt($("#tablebtn").attr("tid"));
		if(tid==0){
			layer.msg("请输入餐桌",{icon:2,time: 2000});
			return false;
		}
		fun_statrTable(tid);
		return false;
	});
});
function fun_statrTable(tid){
	tids=tid ? tid : "{php echo $_GPC['selfttableid']}";
	if(!tids)return;
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('phone',array('op'=>'startorder'))}",{tid:tids},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			var _isnew=false;
			if(parseInt(result.trade.isaddorder)==0 && parseInt(result.trade.person)==0)_isnew=true;
			OrderStart(_isnew);
			fun_formatMenu(result.table,result.trade,result.goods,result.tradelist);
		}else{
			layer.msg(result.msg,{icon:2,time: 2000});
			return false;
		}
	})
}
function fun_formatMenu(table,trade,goods){
	$("#sub_orderid").val(trade.id);
	$("#sub_person").val(trade.person);
	$("#sub_tid").val(table.id);
	$("#count_price").val("￥ "+fee2num(trade.order_fee));
	$("#count_num1").val();
	$("#count_num").val(trade.num);
	$("#count_teafee").val(trade.teafee).attr({"teafee":table.teafee,"perperson":table.perperson});
	$("#count_person").val(trade.person);
	$("#menulist").empty();
	if(!goods)return;
	var key=1;
	for(var i in goods){
		var temp='<tr isnew="false" mid="'+goods[i].id+'" title="'+goods[i].title+'" goodsn="'+goods[i].goodsn+'" gid="'+goods[i].goodid+'" price="'+goods[i].price+'" mprice="'+goods[i].memberprice+'" oprice="'+goods[i].oldprice+'"><td class="index">'+key+'</td><td><span class="til">'+goods[i].title+'</span><div class="goodinfo"><div class="taste">'+goods[i].taste+'</div></div></td><td class="tableNum"><input type="text" class="tnum" value="'+goods[i].num+'"/></td><td class="tprice">'+goods[i].price+'</td><td class="ttotal">'+fee2num(goods[i].total_fee)+'</td><td class="tstatus"><span class="layui-badge layui-bg-orange">下单</span>';
		if(parseInt(goods[i].finishtime))temp+='<span class="layui-badge finish">已上</span>';
		temp+='</td><td><a href="javascript:fun_showbtn(this)" class="layui-btn layui-btn-small">更多</a></td></tr>';
		$("#menulist").append(temp);
		key++;
	}
	count_total();
}
function objectPos(){
	var _w=$(window).width();
	var _h=$(window).height();
	var __h=$(".loginbox").height();
	$(".loginbox").css("margin-top",(_h-__h)*0.5);
	$(".goodlistbox").height(_h-75);
	$(".goodlistbox .swiper-container").height(_h-75);
}
function mdl_selectperson(){
	if(arguments.length>0){
		layer.open({
			type:1,
			title:"输入密码",
			area:"400px",
			skin:'layui-layer-rim',
			content:$(".modal_selectperson").show(),
			success: function(layero, index){
				$("#moadConterInput").attr("type","password").val("");
				$("#modal_selectpersonbtn").bind("click",function(){
					var num=$('#moadConterInput').val();
					if(num==0 || num.length<4){
						layer.msg("请输入密码",{icon:2,time: 2000});
						return;
					}
					$("#mpassword").val(num);
					layer.close(index);
				});
				$("#modal_selectpersonclosebtn").bind("click",function(){
					layer.close(index);
				});
			},
			end:function(){
				$(".modal_selectperson").hide();
				$("#modal_selectpersonbtn").unbind("click");
				$("#modal_selectpersonclosebtn").unbind("click");
			}
		});

	}else{
		layer.open({
			type:1,
			title:"选择就餐人数",
			area:"400px",
			skin:'layui-layer-rim',
			content:$(".modal_selectperson").show(),
			success: function(layero, index){
				var person=$("#personbtn").attr("person");
				$("#moadConterInput").attr("type","text").val(person);
				$("#modal_selectpersonbtn").bind("click",function(){
					var num=parseInt($('#moadConterInput').val());
					if(num==0 || isNaN(num)){
						layer.msg("请输入正确的数字",{icon:2,time: 2000});
						return;
					}
					$("#personbtn").text(num+"人").attr("person",num);
					layer.close(index);
				});
				$("#modal_selectpersonclosebtn").bind("click",function(){
					layer.close(index);
				});
			},
			end:function(){
				$(".modal_selectperson").hide();
				$("#modal_selectpersonbtn").unbind("click");
				$("#modal_selectpersonclosebtn").unbind("click");
			}
		});
	}
}
function fun_person(){
	layer.open({
		type:1,
		title:"修改就餐人数",
		area:"400px",
		skin:'layui-layer-rim',
		content:$(".modal_selectperson").show(),
		success: function(layero, index){
			$(".modal_selectperson .teger").show();
			$(".modal_selectperson .float").hide();
			var person=$("#count_person").val();
			$("#moadConterInput").attr("type","text").val(person);
			$("#modal_selectpersonbtn").bind("click",function(){
				var num=parseInt($('#moadConterInput').val());
				if(num==0 || isNaN(num)){
					layer.msg("请输入正确的数字",{icon:2,time: 2000});
					return;
				}
				$("#count_person").val(num);
				layer.close(index);
			});
			$("#modal_selectpersonclosebtn").bind("click",function(){
				layer.close(index);
			});
		},
		end:function(){
			$(".modal_selectperson").hide();
			$("#modal_selectpersonbtn").unbind("click");
			$("#modal_selectpersonclosebtn").unbind("click");
		}
	});
}
function mdl_selecttable(){
	var _w=$(window).width()-30;
	var _h=$(window).height()-30;
	layer.open({
		type: 1,
		title:0,
		area:[_w+"px",_h+"px"],
		skin: 'layui-layer-rim',
		content:$(".modal_selecttable").show(),
		success: function(layero, index){
			if(tablePcateswiper==null || tablePcateswiper==="undefined"){
				tablePcateswiper = new Swiper('.pt_menubar', {
					slidesPerView: 6,
					spaceBetween:1
				});
			}
			fun_selectTablePcate(0);
		},
		end:function(){
			$(".modal_selecttable").hide();
			$("#modal_selectpersonbtn").unbind("click");
		}
	});
}
function fun_selectTablePcate(pcate){
	if(pcate==0){
		$(".pt_menuitem").eq(0).addClass("isselect").siblings().removeClass("isselect");
	}else{
		$(".pt_menuitem[tcid='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	}
	var pcate=$(".pt_menubar .isselect").attr("tcid");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('phone',array('op'=>'getpcatetable'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			var _h=$(window).height()-$(".pt_menubar").height()-85;
			var _w=$(window).width()-45;
			$(".pt_tablelist").height(_h);
			if(tableSwiper==null || tableSwiper==="undefined")tableSwiper=new Swiper('.pt_tablelist',{direction :'vertical',});
			tableSwiper.removeAllSlides();
			var list=result.list;
			if(list.length==0){
				tableSwiper.destroy(true);
				$('.pt_tablelist .swiper-wrapper').text("暂无内容");
				return;
			}
			var tempAry=[];
			var key=0;
			var psize=10;
			var _w1=parseInt(_w*0.2)>150 ? 150 : parseInt(_w*0.165);
			psize=parseInt(_w/_w1)*parseInt(_h/100);
			for(var i in list){
				if(key==psize){
					tableSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
					key=0;
					tempAry=[];
				}
				var temp='<li class="status_'+list[i].status+'" tid="'+list[i].id+'" status="'+list[i].status+'" onclick="fun_selectTable('+list[i].id+')"><a href="javascript:"><h3>'+list[i].title+'</h3><div class="pt_maxnum text-center">'+list[i].maxnum+'人桌</div><div class="pt_time text-center">';
				switch(parseInt(list[i].status)){
					case 0:
						temp+='<span class="layui-badge layui-bg-green">空闲</span>';
					break;
					case 1:
						temp+='<span class="layui-badge layui-bg-cyan">已开台</span>';
					break;
					case 2:
						temp+='<span class="layui-badge layui-bg-blue">已点菜</span>';
					break;
					case 3:
						temp+='<span class="layui-badge layui-bg-orange">预定</span>';
					break;
				}
				if(parseInt(list[i].ispay))temp+=' <span class="layui-badge">已付款</span>';
				if(parseInt(list[i].ismore))temp+=' <span>拼桌</span>';
				temp+='</div>';
				if(parseInt(list[i].status)==1 && parseInt(list[i].status)==2){
					temp+='<div class="pt_time text-center">'+_getTableTime(list[i].createtime)+'</div>';
				}
				temp+='</a></li>';
				tempAry.push(temp);
				key++;
			}
			if(tempAry.length>0){
				tableSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
			}
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return;
		}
	});
}
function fun_selectTable(tid){
	var title=$(".pt_tablelist li[tid='"+tid+"']").find("h3").text();
	$("#tablebtn").attr("tid",tid).text("选择餐台："+title);
	layer.closeAll();
}
function Counter(num,obj){
	var vTecla=num;
	var salida=$(obj);
	if(vTecla=='C'){
		salida.val('0');
		return false;
	}
	if(vTecla=='B'){
		var temp1=salida.val();
		salida.val(temp1.substr(0,temp1.length-1));
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	if(salida.val().length>8){
		return false;	
	}
	if(vTecla=='.'){
		if(salida.val().indexOf('.')>-1){
			salida.val(salida.val());
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else if(vTecla=='0'){
		if(salida.val()==0 && salida.val().length==1){
			salida.val(0);
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else{
		if((salida.val()==0 && salida.val().length==1)){
			salida.val(vTecla);
		}else{
			salida.val(salida.val()+vTecla);
		} 
	}
	var temp=salida.val();
	if(temp.indexOf('.')>-1){
		var float=temp.split('.');
		if(float[1].length>2){
			salida.val(float[0]+'.'+float[1].substr(0,2));
		}
	}
}
function _getTableTime(timestamp){
	nowTimestamp = Date.parse(new Date());
	nowTimestamp = parseInt(nowTimestamp*0.001)-timestamp
	return parseInt(nowTimestamp/60)+"分钟";
}

function OrderStart(isnew){
	if(isnew){
		$("#count_person").click();
	}
	$(".loginbox").hide();
	$(".orderbox").show();
	var _h=$(window).height()-30;
	$(".countbar").height(_h).css("top",_h-20);
	$(".menulistbox").height(_h-90);
	if($(".goodpcatelist ul li").size()){
		var pcate=parseInt($(".goodpcatelist ul li").eq(0).attr("gcid"));
		fun_selectgoodpcate(pcate);
	}
}
function fun_mainFun(index){
	if($(".mainmenubtn li[cid="+index+"]").hasClass("isselect"))return;
	$(".mainmenubtn li[cid="+index+"]").addClass("isselect").siblings().removeClass("isselect");
	layer.closeAll();
	if(index==0){
		//$(".mianpage").eq(0).show().siblings().hide();
		goodsListSwiper = new Swiper('.goodlistbox .swiper-container',{direction :'vertical',pagination : '.swiper-pagination',});
	}else if(index==1){
		//$(".mianpage").eq(1).show().siblings().hide();
	}else if(index==2){
		layer.open({
			type:1,
			title:0,
			area:"400px",
			skin:'layui-layer-rim',
			content:$(".modal_service").show(),
			end:function(){
				$(".modal_service").hide();
			}
		});
	}else if(index==3){
		
		needPass(2);
	}else if(index==4){
		layer.confirm('确认退出？', function(){
			var index2=layer.load(1, {shade: [0.1,'#fff']});
			$.post("{php echo $this->createMobileUrl('phone',array('op'=>'logout'))}",{},function(returnstr){
				layer.close(index2);
				var result=eval("("+returnstr+")");
				if(result.success){
					location.reload();
				}else{
					layer.msg(result.msg,{icon:2,time: 2000});
					return;
				}
			});
		});
	}
}
function fun_selectgoodpcate(pcate){
	$(".goodpcatelist li[gcid='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('phone',array('op'=>'getpcategood'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		//console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			if(goodsListSwiper==null)goodsListSwiper = new Swiper('.goodlistbox .swiper-container',{pagination : '.swiper-pagination',direction :'vertical',});
			goodsListSwiper.removeAllSlides();
			var list=result.list;
			if(list.length==0)return;
			var tempAry=[];
			var key=0;
			/*面积计算*/
			var height=$(".goodlistbox").height();
			var temp_size=parseInt(height/167)*5;
			var psize=temp_size;
			for(var i in list){
				if(key==psize){
					goodsListSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
					key=0;
					tempAry=[];
				}
				var temp='<li gid="'+list[i].id+'" title="'+list[i].title+'" goodsn="'+list[i].goodsn+'" store="'+list[i].store+'" price="'+list[i].marketprice+'" mprice="'+list[i].memberprice+'"><div class="gbox"><p><img src="'+list[i].thumb+'" onerror="this.src=\'{MODULE_URL}/template/resources/img/002.png\'" /></p><h3>'+list[i].title+'</h3><div onClick="fun_addgood('+list[i].id+')"><span>￥'+list[i].marketprice+'</span><span class="pull-right"><i class="fa fa-shopping-cart"></i></span></div></div>';
				if(pcate==-1){
					temp+='<span class="labels">'+list[i].title2+'</span>';
				}
				temp+='</li>';
				tempAry.push(temp);
				key++;
			}
			if(tempAry.length>0){
				goodsListSwiper.appendSlide('<div class="swiper-slide"><ul>'+tempAry.join(" ")+'</ul></div>');
			}
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return;
		}
	})
}
function fun_showmenu(){
	var top=parseInt($(".countbar").css("top").replace("px"));
	if(top<=30){
		var _h=$(".countbar").height()-20;
		Let('.countbar')
			.set("top",_h)
			.end(function (){
				$(".countbar_menu").hide();
			});
	}else{
		$(".countbar_menu").show();
		Let('.countbar')
			.set("top",30)
			.end();
	}
}
function fun_addgood(id){
	var target=$(".goodlistbox li[gid='"+id+"']");
	addCart(target);
	var price=target.attr("price");
	var mprice=target.attr("mprice");
	var title=target.attr("title");
	var goodsn = target.attr("goodsn");
	var store=parseInt(target.attr("store"));
	if(store==0){
		layer.msg("商品库存不足",{icon:2,time:1000});
		return;
	}
	var temp='<tr isnew="true" mid="0" title="'+title+'" goodsn="'+goodsn+'" gid="'+id+'" price="'+price+'" mprice="'+mprice+'" oprice="'+price+'"><td class="index"></td><td><span class="til">'+title+'</span><div class="goodinfo"><div class="taste"></div></div></td><td class="tableNum"><span>-</span> <input type="text" class="tnum" value="1"/> <span>+</span></td><td class="tprice">'+price+'</td><td class="ttotal">'+price+'</td><td class="tstatus"></td><td><a href="javascript:fun_showbtn(this)" class="layui-btn layui-btn-small">更多</a></td></tr>';
	if($("#menulist tr").size()==0){
		$("#menulist").append(temp);
	}else{
		$(temp).insertBefore($("#menulist tr:eq(0)"));	
	}
	
	$("#menulist tr").each(function(index, element) {
        $(this).find(".index").text(index+1);
    });
	count_total();
}
function fun_showbtn(rowid){
	layer.open({
		type:1,
		title:0,
		area:"400px",
		skin:'layui-layer-rim',
		content:$(".modal_morebtn").show(),
		success: function(layero, index){
			$(".modal_morebtnbox #rowid").val(rowid);
			var mid=parseInt($("#menulist tr:eq("+rowid+")").attr("mid"));
			if(mid){
				$(".modal_morebtn .b1").hide();
				$(".modal_morebtn .b4").hide();
				if($("#menulist tr:eq("+rowid+")").find(".finish").size()){
					$(".modal_morebtn .b3").hide();
				}else{
					$(".modal_morebtn .b3").show();
				}
			}else{
				$(".modal_morebtn .b1").show();
				$(".modal_morebtn .b4").show();
				$(".modal_morebtn .b3").hide();
			}
		},
		end:function(){
			$(".modal_morebtn").hide();
		}
	});
}
function fun_morebtn(types){
	var rowid=$("#rowid").val();
	layer.closeAll();
	switch(types){
		case 0:
			layer.open({
				type: 1,
				title:"选择口味",
				area:'440px',
				skin: 'layui-layer-rim',
				content:$(".modal_taste").show(),
				btn:['确认','取消'],
				btn1:function(index,layero){
					var temp=[];
					$(".modal_taste .isselect").each(function(index, element) {
                        temp.push($(this).text());
                    });
					if(!$("#menulist tr:eq("+rowid+")").find(".taste").size()){
						$("#menulist tr:eq("+rowid+")").find(".goodinfo").append("<span class='taste'>"+temp.join(',')+"</div>");
					}else{
						$("#menulist tr:eq("+rowid+")").find(".taste").text(temp.join(','));
					}
					layer.close(index);
					
				},
				success: function(layero, index){
					var taste = $("#menulist tr:eq("+rowid+")").find(".taste").text();
					if(taste.length){
						var temp=taste.split(",");
						for(var i=0;i<temp.length;i++){
							$(".modal_taste span[taste='"+temp[i]+"']").addClass("isselect");
						}
					}
					$(".modal_taste span").bind("click",function(){
						if($(this).hasClass("isselect")){
							$(this).removeClass("isselect");
						}else{
							$(this).addClass("isselect");
						}
					});
				},
				end:function(){
					$(".modal_taste").hide();
					$(".modal_taste span").unbind("click");
					$(".modal_taste span").removeClass("isselect");
				}
			});
		break;
		case 1:
			var target=$("#menulist tr:eq("+rowid+")");
			var oldprice=target.attr("oprice");
			var nowprice=target.attr("price");
			layer.open({
				type:1,
				title:"修改价格，当前价格：￥"+nowprice+"；原价：￥"+oldprice,
				area:"400px",
				skin:'layui-layer-rim',
				content:$(".modal_selectperson2").show(),
				success: function(layero, index){
					$('#moadConterInput2').val("0");
					$("#modal_selectpersonbtn2").bind("click",function(){
						var price=parseFloat($('#moadConterInput2').val());
						if(price==0 || isNaN(price)){
							layer.msg("请输入正确的数字",{icon:2,time: 2000});
							return;
						}
						target.attr("price",price.toFixed(2));
						target.find(".tprice").text(price.toFixed(2));
						var number=parseInt(target.find(".tnum").val());
						var totalfee=fee2num(price*100*number);
						target.find(".ttotal").text(totalfee);
						count_total();
						layer.close(index);
					});
					$("#modal_selectpersonclosebtn2").bind("click",function(){
						layer.closeAll();
					});
				},
				end:function(){
					$("#modal_selectperson2").hide();
					$("#modal_selectpersonbtn2").unbind("click");
					$("#modal_selectpersonclosebtn2").unbind("click");
				}
			});
		break;
		case 2:
			var target=$("#menulist tr:eq("+rowid+")");
			var mid=target.attr("mid");
			if(!mid){
				layer.msg("该商品还没有下单",{icon:2,time:1000});
				return;
			}
			if(target.find(".finish").size()){
				layer.msg("不能重复上菜",{icon:2,time:1000});
				return;
			}
			layer.confirm('确认上菜？', {icon:3,title:"订单修改提示"}, function(index){
				layer.close(index);
				var index2=layer.load(1, {shade: [0.1,'#fff']});
				$.post("{php echo $this->createMobileUrl('phone',array('op'=>'finishgood'))}",{mid:mid},function(returnstr){
					layer.close(index2);
					console.log(returnstr);
					var result=eval("("+returnstr+")");
					if(result.success){
						if(!target.find(".finish").size())target.find(".tstatus").append('<span class="layui-badge finish">已上</span>');
						layer.msg("操作成功",{icon:1,time:1000});
						count_total();
					}else{
						layer.msg(result.msg,{icon:2,time:1000});
						return;
					}
				});
			});
		break;
		case 3:
			var target=$("#menulist tr:eq("+rowid+")");
			if(parseInt(target.attr("mid"))){
				layer.confirm('该商品已下单，请确认是否已制作。点击[确认]进行删除', {icon:3,title:"订单修改提示"}, function(index){
					$("#menulist tr:eq("+rowid+")").remove();
					count_total();
				    layer.close(index);
				});
			}else{
				$("#menulist tr:eq("+rowid+")").remove();
				count_total();
			}
		break;
	}
}
function count_total(){
	var num=0;
	var totalfee=0;
	$("#menulist tr").each(function(index, element) {
        num+=parseInt($(this).find(".tnum").val());
		totalfee+=parseInt(parseFloat($(this).find(".ttotal").text())*100);
		$(this).find("a").attr("href","javascript:fun_showbtn("+index+")");
    });
	var num1=$("#menulist .finish").size();
	var perperson=parseInt(parseFloat($("#count_teafee").attr("perperson"))*100);
	var atless=parseInt(parseFloat($("#count_teafee").attr("teafee"))*100);
	var person=parseInt($("#count_person").val());
	var teafee=((perperson*person+atless)*0.01).toFixed(2);
	$("#count_price").val("￥ "+(totalfee*0.01).toFixed(2));
	$("#count_num1").val(num1);
	$("#count_num").val(num);
	$("#count_teafee").val(teafee);
}
function addCart(target){
	var offset = $(".counterbtn").offset();
	var img = target.find('img').attr('src');
	var flyer = $('<img class="u-flyer"  src="'+img+'"/>');
	$(".ainmin img").attr("src","{MODULE_URL}template/resources/img/aim_0.png");
	$(".ainmin").css({"top":offset.top-60,"left":offset.left-12,}).show();
	flyer.fly({
		start: {
			left: event.pageX-50,
			top: event.pageY-50
		},
		end: {
			left: offset.left+20,
			top: offset.top+10,
			width: 0,
			height: 0
		},
		onEnd: function(){
			$(".ainmin img").attr("src","{MODULE_URL}template/resources/img/aim_1.png");
			$(".ainmin").fadeOut(500);
			this.destory();
		}
	});
}
function fun_munebtn_submitorder(){
	if(!$("#menulist tr").size()){
		layer.msg("请先添加商品",{icon:2,time:1000});
		return;
	}
	var orderid=$("#sub_orderid").val();
	var person=$("#count_person").val();
	
	var param=[];
	$("#menulist tr").each(function(index, element) {
        var id=$(this).attr("mid")!="undefined" ? $(this).attr("mid") : "";
		var goodid=$(this).attr("gid");
		var price=$(this).attr("price");
		var mprice=$(this).attr("mprice");
		var oprice=$(this).attr("oprice");
		var title=$(this).attr("title");
		var goodsn=$(this).attr("goodsn");
		var num=$(this).find(".tnum").val();
		var fee=$(this).find(".ttotal").text().replace("￥","");
		var taste=$(this).find(".taste").text();
		var ispack=$(this).find(".ispack").size();
		var temp=id+"|"+goodid+"|"+goodsn+"|"+title+"|"+price+"|"+mprice+"|"+oprice+"|"+num+"|"+fee+"|"+ispack+"|"+taste;
		param.push(temp);
    });
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('phone',array('op'=>'submitorder'))}",{param:param,orderid:orderid,person:person},function(returnstr){
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			layer.msg("下单成功",{icon:1,time:1000},function(){
				var index2=layer.load(1, {shade: [0.1,'#fff']});
				var tid=$("#sub_tid").val();
				$.post("{php echo $this->createMobileUrl('phone',array('op'=>'startorder'))}",{tid:tid},function(returnstr){
					layer.close(index2);
					var result=eval("("+returnstr+")");
					if(result.success){
						fun_formatMenu(result.table,result.trade,result.goods,result.tradelist);
					}else{
						layer.msg(result.msg,{icon:2,time: 2000});
						return;
					}
				});
			});
			
		}else{
			layer.close(index2);
			layer.msg(result.msg,{icon:2,time:1000});
			return;
		}
		
	});
}

function needPass(types){
	layer.open({
		type:1,
		title:"请输短密码",
		area:"400px",
		skin:'layui-layer-rim',
		content:$(".modal_selectperson").show(),
		success: function(layero, index){
			$("#moadConterInput").attr("type","password").val("");
			var shortpass="{$_GPC['shortpass']}";
			$("#modal_selectpersonbtn").bind("click",function(){
				var num=$('#moadConterInput').val();
				if(num!=shortpass){
					layer.msg("密码错误",{icon:2,time: 2000});
					return;
				}
				layer.close(index);
				switch(types){
					case 1:
						fun_morebtn(1);
					break;
					case 2:
						var index2=layer.load(1, {shade: [0.1,'#fff']});
						$.post("{php echo $this->createMobileUrl('phone',array('op'=>'clearorderid'))}",{},function(returnstr){
							location.reload();
						});
					break;
				}
			});
			$("#modal_selectpersonclosebtn").bind("click",function(){
				layer.close(index);
			});
			
		},
		end:function(){
			$(".modal_selectperson").hide();
			$("#modal_selectpersonbtn").unbind("click");
			$("#modal_selectpersonclosebtn").unbind("click");
		}
	});
}
function fun_callservice(txt){
	var timestamp = parseInt(Date.parse(new Date())*0.001);
	var oldTime=parseInt($(".modal_servicebox").attr("time"));
	if(timestamp-oldTime<60*1){
		layer.msg("呼叫过于频繁，请稍后再试",{icon:2,time: 2000});
		return;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	var tid=$("#sub_tid").val();
	$.post("{php echo $this->createMobileUrl('phone',array('op'=>'callsevice'))}",{tid:tid,txt:txt},function(returnstr){
		layer.closeAll();
		var result=eval("("+returnstr+")");
		if(result.success){
			$(".modal_servicebox").attr("time",timestamp);
			layer.msg("呼叫成功",{icon:1,time: 1500});
		}else{
			layer.msg(result.msg,{icon:2,time: 2000});
			return;
		}
	});
}
</script>
{/if}